﻿using System.Configuration;
using System;

namespace Zove.Desktop {
    public sealed class DesktopUtils {

        public static string ConstantFile {
            get {
                return ConfigurationManager.AppSettings["constant"];
            }
            set {
                ConfigurationManager.AppSettings["constant"] = value;
            }
        }

        public static string FunctionPath {
            get {
                return ConfigurationManager.AppSettings["functions"];
            }
            set {
                ConfigurationManager.AppSettings["functions"] = value;
            }
        }

        public static bool ShowToolBar {
            get {
                return
                    Convert.ToBoolean(
                    ConfigurationManager.AppSettings["Toolbar"]);
            }
            set {
                ConfigurationManager.AppSettings["Toolbar"] = value.ToString();
            }
        }

        public static bool ShowStatusBar {
            get {
                return 
                    Convert.ToBoolean(
                    ConfigurationManager.AppSettings["Statusbar"]);
            }
            set {
                ConfigurationManager.AppSettings["Statusbar"] = value.ToString();
            }
        }


        /// <summary>
        /// default workspace to be opened every time Zove Desktop starts
        /// </summary>
        public static string DefaultWorkspace {
            get {
                return ConfigurationManager.AppSettings["Default Workspace"];
            }
            set {
                ConfigurationManager.AppSettings["Default Workspace"] = value;
            }
        }

        public static string Font {
            get {
                return ConfigurationManager.AppSettings["font"];
            }
            set {
                ConfigurationManager.AppSettings["font"] = value;
            }
        }

        /// <summary>
        /// remembers the last workspaces
        /// </summary>
        public static string Workspaces {
            get {
                return ConfigurationManager.AppSettings["workspaces"];
            }
            set {
                ConfigurationManager.AppSettings["workspaces"] = value;
            }
        }

        public static float FontSize {
            get {
                return float.Parse(
                    ConfigurationManager.AppSettings["font-size"]);
            }
            set {
                if (value == null) {
                    return;
                }

                ConfigurationManager.AppSettings["font-size"] = value.ToString();
            }
        }

        public static string Extensions {
            get {
                return ConfigurationManager.AppSettings["extension"];
            }
            set {
                ConfigurationManager.AppSettings["extension"] = value;
            }
        }

        public static string ModelPool {
            get {
                return System.Environment.CurrentDirectory 
                    + "\\" + ConfigurationManager.AppSettings["models"];
            }
            set {
                ConfigurationManager.AppSettings["models"] = value;
            }
                
        }

        public static string ModelTemplateFile {
            get {
                return ConfigurationManager.AppSettings["ModelTemplateFile"];
            }
            set {
                ConfigurationManager.AppSettings["ModelTemplateFile"] = value;
            }
        }

        public static string ProgramTemplateFile {
            get {
                return ConfigurationManager.AppSettings["ProgramTemplateFile"];
            }
            set {
                ConfigurationManager.AppSettings["ProgramTemplateFile"] = value;
            }
        }

        public static string Precision {
            get {
                return ConfigurationManager.AppSettings["precision"];
            }
            set {
                ConfigurationManager.AppSettings["precision"] = value;
            }
        }
    }
}
